package cn.com.egova.erp.biz.impl;

import cn.com.egova.erp.biz.IStoredetailBiz;
import cn.com.egova.erp.dao.IGoodsDao;
import cn.com.egova.erp.dao.IStoreDao;
import cn.com.egova.erp.dao.IStoredetailDao;
import cn.com.egova.erp.entity.Storedetail;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 仓库库存业务逻辑类
 *
 * @author Administrator
 */
public class StoredetailBiz extends BaseBiz<Storedetail> implements IStoredetailBiz {

    private IStoredetailDao storedetailDao;
    private IStoreDao storeDao;
    private IGoodsDao goodsDao;

    public void setStoredetailDao(IStoredetailDao storedetailDao) {
        this.storedetailDao = storedetailDao;
        super.setBaseDao(this.storedetailDao);
    }

    public void setStoreDao(IStoreDao storeDao) {
        this.storeDao = storeDao;
    }

    public void setGoodsDao(IGoodsDao goodsDao) {
        this.goodsDao = goodsDao;
    }

    @Override
    public List<Storedetail> getListByPage(Storedetail storedetail1, Storedetail storedetail2, Object param, int firstResult, int maxResults) {
        List<Storedetail> list = super.getListByPage(storedetail1, storedetail2, null, firstResult, maxResults);
        Map<Long, String> storeNameMap = new HashMap<>();
        Map<Long, String> goodsNameMap = new HashMap<>();
        for (Storedetail storedetail : list) {
            storedetail.setStoreName(storeDao.getName(storedetail.getStoreuuid(), storeNameMap, "getName"));
            storedetail.setGoodsName(goodsDao.getName(storedetail.getGoodsuuid(), goodsNameMap, "getName"));
        }
        return list;
    }
}
